<template>
     <ztree  :data="data"
            @nodeClick="nodeClick"
            @selectUser="selectUser"
            @loading="loading"
            :isLoading="isLoading"
            :show-checkBox="showCheckBox"
            :name="'departName'">
            </ztree>
</template>
<script>
import ztree from "./index";
import { Scroller } from "vux";
export default {
  components: {
    ztree,
    Scroller
  },
  data() {
    return {
      data: [],
      users: [],
      showCheckBox:true,
      isLoading: false
    };
  },
  props: {
    deptId: {
      type: String,
      default: '-1'
    }
  },
  mounted() {
    this.$axiosAjax
      .examinedUnits({ parentId: this.deptId })
      .then(res => {
        if (res.data.success == true) {
          this.data = res.data.result;
        }
      })
      .catch(err => {});
  },
  methods: {
    nodeClick(data) {
      this.$axiosAjax
        .getUserList({ departId: data.id, skipCount: 0, maxResultCount: 100 })
        .then(res => {
          if (res.data.success == true) {
            data.users = res.data.result.items;
          }
        })
        .catch(err => {});
    },
    selectUser(data) {
      this.$emit("selectUser", data);
    },
    loading(val) {
      this.isLoading = val;
    }
  }
};
</script>

